package com.neutech.controller;

import com.neutech.service.CaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
public class CaseController {
    @Autowired
    private CaseService caseService;


    @RequestMapping("/case")
    public List<Map<String,Object>> getCase(){
        System.out.println(caseService.queryCase());
        return caseService.queryCase();
    }

    @RequestMapping("/insertcase")
    public void insCase(@RequestParam Map  map){
        caseService.insertCase(map);
        System.out.println(map.get("uid"));
    }
    @RequestMapping("/deleteCase")
    public void delCase(@RequestParam Map  map){
        caseService.deleteCase(map);
        System.out.println(map.get("uid"));

    }
    @RequestMapping("/updataCase")
    public void updCase(@RequestParam Map  map){
          System.out.println("看这里");
//        System.out.println(map);
//        System.out.println("看这里");
  Map<String,Object> map2 = new HashMap<>();
//        map2.put("disid",map.get("disid"));
//        map2.put("name",map.get("name"));
//        map2.put("sort",map.get("sort"));
//        map2.put("item",map.get("item"));
//        map2.put("dep",map.get("dep"));
//        map2.put("whe",map.get("whe"));
//        map2.put("price",map.get("price"));

      caseService.updataCase(map2);
}

@RequestMapping("/delCaseById")
public String delCaseById(Integer uid){
        caseService.delCaseByIdBiz(uid);
        return "删除成功";
}
}
